<template>
	<view class="template-advertise">
		<rich-text :nodes="body"></rich-text>
	</view>
</template>

<script>
	import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
	export default {
		name: 'templateAdvertise',
		mixins: [template_page_mixin],
		data() {
			return {
				title: '',
				id: 0,
				body: '',
				type: 'pages',
			}
		},
		onLoad(option) {

			if (option.id) {
				this.id = option.id
			}
			if (option.type) {
				this.type = option.type
			}
			if (option.title) {
				this.title = option.title

			}

			this.info()

		},
		onReady() {

		},

		methods: {

			async info() {
				try {
					let that = this;
					let result = await that.$request({
						loading: 1,
						method: 'post',
						url: '/api/index/page',
						data: {
							id: that.id,
							type: that.type,
							title: that.title
						}
					});
					that.title = result.data.data.title
					result.data.data.detail=result.data.data.detail.replace(/img/gi,'img style="width: 100%"')
					that.body = result.data.data.detail;
					uni.setNavigationBarTitle({
						title: that.title
					})
				} catch (e) {
					uni.showToast({
						icon: 'none',
						title: e.data.msg
					});
				}
			},


		}
	}
</script>

<style lang="scss" scoped>
  p{
    padding: 5px 10px !important;
    border-radius: 8px;
    color: #333333;
  }
	.template-advertise {
		padding: 30rpx;
		color: #FFFFFF;

	}
</style>
